import { BrowserWindow } from 'electron'
import { is } from '@electron-toolkit/utils'
import { windowConfig } from '../config/window'
import { join } from 'path'

let loginWindow = null

export function createLoginWindow() {
  loginWindow = new BrowserWindow(windowConfig.login)

  loginWindow.on('ready-to-show', () => {
    loginWindow.show()
  })

  if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
    loginWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
  } else {
    loginWindow.loadFile(join(__dirname, '../../renderer/index.html'))
  }

  return loginWindow
}

export function closeLoginWindow() {
  if (loginWindow) {
    loginWindow.close()
    loginWindow = null
  }
} 